
import '../Role_management/roleNew.scss'
import '../../static/font/iconfont.css'
import { Form, Input, Button, Select, Image, Modal, Upload } from 'antd';
import { ExclamationCircleOutlined, InboxOutlined, UploadOutlined } from '@ant-design/icons';
import Avatar from './Upload'
import { useEffect, useState } from 'react';
import store from '../../store/index'
import http from '../../utils/http'
const { Option } = Select;
const { confirm } = Modal;
const layout = {
    labelCol: {
        span: 6,
    },
    wrapperCol: {
        span: 14,
    },
};
const tailLayout = {
    wrapperCol: {
        offset: 8,
        span: 16,
    },
};

const TenDetail = ({ setState }) => {
    //返回页面'
    // const [form] = Form.useForm();
    const [form1] = Form.useForm();
    const [form2] = Form.useForm();
    const [form3] = Form.useForm();
    const [src, setSrc] = useState('')
    const [src2, setSrc2] = useState('')
    useEffect(() => {
        console.log(store.zengjiayu.tendetailid)
        http({
            url: '/Peree_Person/findPersonInfo',
            method: 'post',
            params: {
                person_id: store.zengjiayu.tendetailid
            }
        }).then((res) => {
            console.log(res)
            if (res.code == 200) {
                let mydata1 = res.data.personInfo[0]
                let mydata2 = res.data.person_pereeVo[0]
                console.log(mydata1)
                form1.setFieldsValue({
                    personName: mydata1.personName,
                    personPhone: mydata1.personPhone,
                    personSex: mydata1.personSex == 0 ? '男' : "女",
                    personEaducation: mydata1.personEaducation,
                    personVx: mydata1.personVx,
                    personPhoto: mydata1.personPhoto,
                })
                form2.setFieldsValue({
                    perType: mydata2.perType == 0 ? '企业' : '个体经营户',
                    person_name: mydata2.personName,
                    ten_serialint: mydata2.tenSerialint,
                    per_logo: mydata2.perLogo,
                    person_type: mydata2.personType == 0 ? '负责人' : '普通员工',
                })
                form3.setFieldsValue({
                    per_name: mydata2.perName,
                    person_phone: mydata2.personPhone,
                    room_no: mydata2.roomNo,
                    person_creatime: getLocalTime(mydata2.personCreatime),
                })
                setSrc(mydata1.personPhoto)
                setSrc(mydata2.perLogo)
            }
        })
    }, [])
    const backCar = () => {
        setState(1)
    }
    const quxiao = () => {
        confirm({
            icon: <ExclamationCircleOutlined />,
            content: '您确定离开此页面吗？',
            cancelText: '取消',
            okText: '确定',
            onOk() {
                //   console.log('OK');
                backCar()
            },
            onCancel() {
                console.log('Cancel');
            },
        });
    }
    const onFinish = (values) => {
        console.log(values);
    };
    const normFile = (e) => {
        console.log('Upload event:', e);

        if (Array.isArray(e)) {
            return e;
        }

        return e && e.fileList;
    };
    // 时间戳转换函数
    function getLocalTime(nS) {
        let date = new Date(nS);
        //时间戳为10位需*1000，时间戳为13位的话不需乘1000
        let y = date.getFullYear();
        let MM = date.getMonth() + 1;
        MM = MM < 10 ? "0" + MM : MM; //月补0
        let d = date.getDate();
        d = d < 10 ? "0" + d : d; //天补0
        // let h = date.getHours();
        // h = h < 10 ? "0" + h : h; //小时补0
        // let m = date.getMinutes();
        // m = m < 10 ? "0" + m : m; //分钟补0
        // let s = date.getSeconds();
        // s = s < 10 ? "0" + s : s; //秒补0
        // return y + "-" + MM + "-" + d + " " + h + ":" + m + ":" + s;
        return y + "-" + MM + "-" + d;
    }
    return (
        <div className="xinzeng">
            <div>
                <div className='tit'>
                    <div>
                        <div>
                            <div></div>
                            <div>人员信息详情</div>
                        </div>
                    </div>
                    <div>
                        <span className="iconfont icon-a-16guanbi" onClick={backCar}></span>
                    </div>
                </div>
                <hr></hr>
                <div className='content'>
                    <div>
                        <p>人员基本信息:</p>
                        <Form {...layout} form={form1} name="control-hooks" onFinish={onFinish}>
                            <Form.Item
                                name="personName"
                                label="人员名称"
                                rules={[
                                    {
                                        required: true,
                                    },
                                ]}
                            >
                                <Input disabled />
                            </Form.Item>
                            <Form.Item
                                name="personPhone"
                                label="联系方式"
                                rules={[
                                    {
                                        required: true,
                                    },
                                ]}
                            >
                                <Input disabled />
                            </Form.Item>
                            <Form.Item
                                name="personSex"
                                label="人员性别"
                                rules={[
                                    {
                                        required: true,
                                    },
                                ]}
                            >
                                <Select
                                    allowClear
                                    disabled
                                >
                                </Select>
                            </Form.Item>
                            <Form.Item
                                name="personEaducation"
                                label="人员学历"

                            >
                                <Input disabled />
                            </Form.Item>
                            <Form.Item
                                name="personVx"
                                label="绑定微信号"
                                rules={[
                                    {
                                        required: true,
                                    },
                                ]}
                            >
                                <Input disabled />
                            </Form.Item>
                            <Form.Item
                                name="personPhoto"
                                label="人脸照片"
                                rules={[
                                    {
                                        required: true,
                                    },
                                ]}
                            >
                                <Image
                                    width={100}
                                    src={src}
                                />
                            </Form.Item>
                        </Form>
                    </div>
                    <div>
                        <p>人员所属信息:</p>
                        <div>
                            <div>
                                <Form {...layout} form={form2} name="control-hooks" onFinish={onFinish}>
                                    <Form.Item
                                        name="perType"
                                        label="租户类型"
                                        rules={[
                                            {
                                                required: true,
                                            },
                                        ]}
                                    >
                                        <Select
                                            allowClear
                                            disabled
                                        >
                                        </Select>
                                    </Form.Item>
                                    <Form.Item
                                        name="person_name"
                                        label="负责人姓名"
                                        rules={[
                                            {
                                                required: true,
                                            },
                                        ]}
                                    >
                                        <Input disabled />
                                    </Form.Item>
                                    <Form.Item
                                        name="ten_serialint"
                                        label="所属楼宇"
                                        rules={[
                                            {
                                                required: true,
                                            },
                                        ]}
                                    >
                                        <Select disabled>
                                            <Select.Option value="A1幢">
                                                A1幢
                                            </Select.Option>
                                            <Select.Option value="B2幢">
                                                B2幢
                                            </Select.Option>
                                            <Select.Option value="C3幢">
                                                C3幢
                                            </Select.Option>
                                        </Select>
                                    </Form.Item>
                                    <Form.Item label="企业LOGO"
                                        name="per_logo"
                                        rules={[{ required: true }]}
                                        style={{
                                            flex: '1',
                                        }}>
                                        <Image
                                            width={100}
                                            src={src2}
                                        />
                                        {/* <Avatar></Avatar> */}
                                    </Form.Item>
                                    <Form.Item
                                        name="person_type"
                                        rules={[{ required: true }]}
                                        label='人员类型'
                                    >
                                        <Select placeholder='请选择' className='select' disabled>
                                            <Option value="1">负责人</Option>
                                            <Option value="2">普通员工</Option>
                                        </Select>
                                    </Form.Item>
                                </Form>
                            </div>
                            <div>
                                <Form {...layout} form={form3} name="control-hooks" onFinish={onFinish}>
                                    <Form.Item
                                        name="per_name"
                                        label="租户名称"
                                        rules={[
                                            {
                                                required: true,
                                            },
                                        ]}
                                    >
                                        <Input disabled></Input>
                                    </Form.Item>
                                    <Form.Item
                                        name="person_phone"
                                        label="联系方式"
                                        rules={[
                                            {
                                                required: true,
                                            },
                                        ]}
                                    >
                                        <Input disabled />
                                    </Form.Item>
                                    <Form.Item
                                        name="room_no"
                                        label="房间名称"
                                        rules={[
                                            {
                                                required: true,
                                            },
                                        ]}
                                    >
                                        <Input disabled />
                                    </Form.Item>
                                    <Form.Item
                                        name="person_creatime"
                                        label="注册时间"
                                        rules={[
                                            {
                                                required: true,
                                            },
                                        ]}
                                    >
                                        <Input disabled />
                                    </Form.Item>
                                </Form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>)
}
export default TenDetail